<?php

namespace Library;

use \Org\Util\MgInterface;

class GameTable
{
    private static $_instance;

    private function __construct() {
    }

    public function __clone() {
        trigger_error('Clone is not allow!', E_USER_ERROR);
    }

    public static function getInstance() {
        $options = array(
            'token'=> C('GM_TOKEN'),
            'appid'=> C('GM_APPID'),
            'appsecret'=> C('GM_APPSERCRET'),
            'logcallback' => SITE_PATH.'/data/runtime/Logs/Game/table.log',
            'debug' => true,
        );

        self::$_instance = new MgInterface($options);
        return self::$_instance;
    }

    public static function __callStatic($method, $arguments) {
        $gt = self::getInstance();
        $reuslt = call_user_func_array(array($gt, $method), $arguments);
        if ($reuslt == FALSE) {
            if ($gt->getErrText == 10001) {
                $reuslt = call_user_func_array(array($gt, $method), $arguments);
            }
        }
        return $reuslt;
    }

    public static function getLastErrCode() {
        $gt = self::getInstance();
        return $gt->getErrText;
    }
}





